# -*- coding:utf8 -*-
# !/usr/bin/python
'''
author: ning.luo
createTime: 2021/12/13 11:14
update: ning.luo
updateTime: 2021/12/13 11:14
description: gitlog基础数据
'''
import gitlab
import requests

class GitLogBasicData:

    def __init__(self):
        GIT_USER = "A99999"
        GIT_PASSWORD = "Comon%4012%23%24"
        self.GIT_TOKEN = "kAaS2V9V774XCtDiqWfb"
        GIT_HOST = "https://gitlab.casstime.net/"
        self.gl = gitlab.Gitlab(GIT_HOST, private_token=self.GIT_TOKEN)

    def get_user(self):
        user_list = []
        users = self.gl.users.list(all=True)
        for i in users:
            name_username_dict = dict()
            name_username_dict["username"] = i.username
            name_username_dict["name"] = i.name
            user_list.append(name_username_dict)
        return user_list

    def get_event(self, user):
        project_id = 3276
        project = self.gl.projects.get(project_id)
        commits = project.commits.list(all=True)
        for commit in commits:
            commit_info = project.commits.get(commit.id)
            print(commit_info.stats)
            print(commit.diff())
            break


    def data_chuli(self):
        pass

if __name__ == "__main__":
    a = GitLogBasicData()
    user_list = a.get_event("a00519")